package com.hgy.commonsale.webui.action;

import java.util.List;
import java.util.Map;

import org.geln.web.status.Status;


import com.hgy.commonsale.service.CustomerUserManagerService;
import com.hgy.commonsale.user.domain.CustomerUser;
import com.opensymphony.xwork.ActionContext;



public class CustomerRegister extends AnonymousAction {
	private String customerEmail;
	private String password;
	private String tel;
	private String company;
	private String realName;
	private CustomerUserManagerService customerUserManagerService;
	private List<CustomerUser> lstCustomer;
	private String userNo;
	

	public CustomerUserManagerService getCustomerUserManagerService() {
		return customerUserManagerService;
	}
	public void setCustomerUserManagerService(
			CustomerUserManagerService customerUserManagerService) {
		this.customerUserManagerService = customerUserManagerService;
	}
	
	
	public String getCustomerEmail() {
		return customerEmail;
	}
	public void setCustomerEmail(String customerEmail) {
		this.customerEmail = customerEmail;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getCompany() {
		return company;
	}
	public void setCompany(String company) {
		this.company = company;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	
	public List getLstCustomer() {
		return lstCustomer;
	}
	
	
	public void setLstCustomer(List<CustomerUser> lstCustomer) {
		this.lstCustomer = lstCustomer;
	}
	
	
	
	public String execute() throws Exception{
		CustomerUser customerUser=new CustomerUser();
		customerUser.setUserNo(customerEmail);
		customerUser.setUserPassword(password);
		customerUser.setUserTel(tel);
		customerUser.setUserCompany(company);
		customerUser.setUserRealName(realName);
		if(customerUser.getUserNo()==null){
			return INPUT;
		}
		Object object=customerUserManagerService.saveObject(customerUser);
		if(object==null){
			return INPUT;
		}else{
			if(Status.SUCCESS.equals(object)){
				return SUCCESS;
			}
		}
		
		return INPUT;
	}
	
	
	public String doGetCustomerList() throws Exception{
		
		lstCustomer=customerUserManagerService.getCustomerUserList();
		return INPUT;
	}
	
	
	
	public String doDeleteOneCustomer() throws Exception{
		
		Status status=customerUserManagerService.deleteObjectByUserName(userNo);
		if(status.equals(Status.SUCCESS)){
			return INPUT;
		}
		else{
			return INPUT;
		}
		
	}
	
	public String getUserNo() {
		return userNo;
	}
	public void setUserNo(String userNo) {
		this.userNo = userNo;
	}

	

}
